package com.hu.network.threadpool;

import android.os.Handler;
import android.os.Looper;

/**
 * 说明：
 *
 * @author ： hucanhua
 * @date ： 2017/10/25
 */
public class NetMainHandler {
    private static NetMainHandler netMainHandler;
    private final Handler handler;
    private NetMainHandler() {
        handler = new Handler(Looper.getMainLooper());
    }

    public static NetMainHandler getInstance() {
        if (netMainHandler == null) {
            synchronized (NetMainHandler.class) {
                if (netMainHandler == null) {
                    netMainHandler = new NetMainHandler();
                }
            }
        }
        return netMainHandler;
    }

    public synchronized void runOnMainThread(Runnable runnable) {
        handler.post(runnable);
    }

}
